/*
 * KinematicsPanel.java -
 * Copyright (c) 2005 Carmine Lia
 * e-mail:      carmine.lia@libero.it
 * web-address: http://www.intermedia.sa.it/lia

 *  This program is free software; you can redistribute it and/or
 *  modify it under the terms of the GNU General Public License
 *  as published by the Free Software Foundation; either version 2
 *  of the License, or any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 *
 */
package javax.robotics.swing;

import java.awt.Color;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;

import javax.robotics.engine.robots.Robot3D;
import javax.swing.BorderFactory;
import javax.swing.JPanel;

/**
 * This class creates a panel with spinner for dir/inv kinematics.
 * 
 * @author <a href="http://www.intermedia.sa.it/lia/">Carmine Lia</a>
 * @since 1.1.1
 * @version 18/11/2005
 * 
 */
public class KinematicsPanel extends JPanel
{
    private static final long serialVersionUID = 3256442499685233201L;

    private final JointSpinnerPanel jointPanel;
    private final TipPanel tipPanel;
    private final JacobianPanel jacobianPanel;

    /**
     * Constructor of the panel.
     * 
     * @param robot
     *            the robot.
     */
    public KinematicsPanel(Robot3D robot)
    {
        this(robot, 0.01);
    }

    /**
     * Constructor of the panel.
     * 
     * @param robot
     *            the robot.
     * @param stepSize
     *            the minumum size of spinners step.
     */
    public KinematicsPanel(Robot3D robot, double stepSize)
    {
        super();
        jointPanel = new JointSpinnerPanel(robot, stepSize);
        tipPanel = new TipPanel(robot, stepSize);
        jacobianPanel = new JacobianPanel(robot);

        setBorder(BorderFactory.createCompoundBorder(BorderFactory
                .createTitledBorder(BorderFactory.createLineBorder(Color.gray),
                        "Kinematics"), BorderFactory.createEmptyBorder(2, 5, 2,
                5)));

        GridBagLayout gbl = new GridBagLayout();
        GridBagConstraints c = new GridBagConstraints();
        c.fill = GridBagConstraints.VERTICAL;
        setLayout(gbl);

        c.gridy = 0;
        add(jointPanel, c);

        c.gridy = 1;
        add(tipPanel, c);
        
        c.gridy = 2;
        add(jacobianPanel, c);
    }

    /**
     * Gets the joints command panel.
     * 
     * @return the joints panel.
     * @see JointSpinnerPanel
     */
    final public JointSpinnerPanel getJointPanel()
    {
        return jointPanel;
    }
    /**
     * Gets the tip (end effector) command panel.
     * 
     * @return the tip panel.
     * @see TipPanel
     */

    final public TipPanel getTipPanel()
    {
        return tipPanel;
    }

}
